package com.minyifang.wcspf.work.ui.user.activities;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.minyifang.wcspf.R;
import com.minyifang.wcspf.common.adapter.GeneralFragmentPagerAdapter;
import com.minyifang.wcspf.common.base.BaseMvpActivity;
import com.minyifang.wcspf.work.ui.goods.model.CommentDesc;
import com.minyifang.wcspf.work.ui.user.fragments.MyCommentFragment;
import com.minyifang.wcspf.work.ui.user.presenter.MyCommentPresenter;
import com.minyifang.wcspf.work.ui.user.view.MyCommentView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 我的评价
 */
public class MyCommentActivity extends BaseMvpActivity<MyCommentView, MyCommentPresenter> implements MyCommentView {

    @BindView(R.id.tl_type)
    TabLayout mTabLayout;
    @BindView(R.id.vp_comment)
    ViewPager mViewPager;

    @Override
    protected int setContentLayoutRes() {
        return R.layout.activity_my_comment;
    }

    @Override
    protected void initView() {
    }

    @Override
    protected void initData() {
        mPresenter.getMyCommentHeadInfo();
    }

    @Override
    protected MyCommentPresenter createPresenter() {
        return new MyCommentPresenter();
    }

    @Override
    public void showLoadingView() {

    }

    @Override
    public void hideLoadingView() {

    }

    @Override
    public void onNetworkError() {

    }

    @Override
    public void onGetMyCommentHeadInfoSucceed(CommentDesc commentDesc) {
        List<String> stringList = new ArrayList<>();
        stringList.add(String.format("全部(%s)", commentDesc.getAllCom()));
        stringList.add(String.format("晒图(%s)", commentDesc.getHavePic()));
        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(MyCommentFragment.newInstance(MyCommentFragment.TYPE_ALL));
        fragmentList.add(MyCommentFragment.newInstance(MyCommentFragment.TYPE_PIC));
        mViewPager.setAdapter(new GeneralFragmentPagerAdapter(getSupportFragmentManager(), fragmentList, stringList));
        mTabLayout.setupWithViewPager(mViewPager);
    }
}
